import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../components/content/Home/Home.vue";
import discoverm from "../views/discoverM/discoverM.vue";
import mymusic from "../views/myMusic/myMusic.vue";
import discover from "../components/content/navlist/discover/discover.vue";
import toplist from "@/components/content/navlist/toplist/toplist.vue";
import Playlist from "@/components/content/navlist/playlist/Playlist.vue";
import djradio from "@/components/content/navlist/djradio/djradio.vue";
import artist from "@/components/content/navlist/artist/artist.vue";
import album from "@/components/content/navlist/album/album.vue";
import result from "@/components/content/result/result.vue";
import playlistdetail from "@/components/content/navlist/playlist/playlistdetail.vue";
import artistdetail from "@/components/content/navlist/artist/artistdetail.vue";
import mymusicLogin from "@/components/content/mymusicLogin/mymusicLogin.vue";
import mymusicartist from "@/components/content/mymusicLogin/mymusicartist.vue";
import mymusicmv from "@/components/content/mymusicLogin/mymusicmv.vue";
import mymusicplaylist from "@/components/content/mymusicLogin/mymusicplaylist.vue";
import newsongs from "@/components/content/navlist/toplist/newsongs.vue";
import hotsongs from "@/components/content/navlist/toplist/hotsongs.vue";
import original from "@/components/content/navlist/toplist/original.vue";
import biaosheng from "@/components/content/navlist/toplist/biaosheng.vue";
import artistcat from "@/components/content/navlist/artist/artistcat.vue";
import lyric from "@/components/content/result/lyric.vue"
Vue.use(VueRouter);

const routes = [
  {
    path: "",
    redirect: "/discover",
  },
  {
    path: "/home",
    component: Home,
  },
  {
    path: "/mymusic",
    component: mymusic,
  },
  {
    path: "/discoverm",
    component: discoverm,
  }, //nav
  {
    path: "/discover",
    component: discover,
  },
  {
    path: "/discover/toplist",
    component: toplist,
  },
  {
    path: "/discover/playlist",
    component: Playlist,
  },
  {
    path: "/discover/djradio",
    component: djradio,
  },
  {
    path: "/discover/artist",
    component: artist,
    children: [
      {
        path: "cat",
        component: artistcat,
        params:{
          id:1001
        }
      },
    ],
  },
  {
    path: "/discover/album",
    component: album,
  },
  {
    path: "/result",
    component: result,
  },
  {
    path: "/playlistdetail",
    component: playlistdetail,
  },
  {
    path: "/artistdetail",
    component: artistdetail,
  },
  {
    path: "/my/m/music",
    component: mymusicLogin,
    children: [
      {
        path: "artist",
        component: mymusicartist,
      },
      {
        path: "mv",
        component: mymusicmv,
      },
      {
        path: "playlist",
        component: mymusicplaylist,
      },
    ],
  },
  {
    path: "/discover/toplist",
    component: toplist,
    children: [
      {
        path: "biaosheng",
        component: biaosheng,
      },
      {
        path: "newsongs",
        component: newsongs,
      },
      {
        path: "original",
        component: original,
      },
      {
        path: "hotsongs",
        component: hotsongs,
      },
    ],
  },
  {
    path:"/song",
    component:lyric
  }
];

const router = new VueRouter({
  routes,
  mode: "history",
});

//挂在路由导航守卫
// router.beforeEach((to, from, next) => {
//   //to 将要访问的路径
//   //from代表从那个路径跳转而来
//   //next是一个函数 表示放行
//   //next有两种方法放心 1）next（）直接放行
//   // 2） next（‘’） 里面加入强制跳转的路径

//   //获取cookie
//   const cookieStr = window.sessionStorage.getItem("cookie");
//   if(!cookie) return next('/mymusic')
// });

export default router;
